
// basic test
test5to3(
'try {\n\
	throw new Error("a");\n\
} catch(e if e.message == "a") {\n\
	print("conditional");\n\
} catch(e) {\n\
	print("unconditional");\n\
}',

'try {\n\
	throw new Error("a");\n\
} catch (e) {\n\
	if (e.message == "a")\n\
		print("conditional");\n\
	else\n\
		print("unconditional");\n\
}'
);

// general catch must be added if missing
test5to3(
'try {\n\
	throw new Error("a");\n\
} catch(e if e.message == "a") {\n\
	print("conditional");\n\
}',

'try {\n\
	throw new Error("a");\n\
} catch (e) {\n\
	if (e.message == "a")\n\
		print("conditional");\n\
	else\n\
		throw e;\n\
}'
);

// general catch must be placed before finally
test5to3(
'try {\n\
	throw new Error("a");\n\
} catch(e if e.message == "a") {\n\
	print("conditional");\n\
} finally {\n\
	print("done");\n\
}',

'try {\n\
	throw new Error("a");\n\
} catch (e) {\n\
	if (e.message == "a")\n\
		print("conditional");\n\
	else\n\
		throw e;\n\
} finally {\n\
	print("done");\n\
}'
);

// exception references must be renamed if general name differs
test5to3(
'try {\n\
	throw new Error("a");\n\
} catch(e if e.message == "a") {\n\
	print("conditional");\n\
} catch(f) {\n\
}',

'try {\n\
	throw new Error("a");\n\
} catch (f) {\n\
	if (f.message == "a")\n\
		print("conditional");\n\
	else {}\n\
}'
);

// two conditional statements
test5to3(
'try {\n\
	throw new Error("Hi!");\n\
} catch (e if e.message == "Hi!") {\n\
	print("received message");\n\
} catch (e if e instanceof Error) {\n\
	print("general exception");\n\
}',

'try {\n\
	throw new Error("Hi!");\n\
} catch (e) {\n\
	if (e.message == "Hi!")\n\
		print("received message");\n\
	else if (e instanceof Error)\n\
		print("general exception");\n\
	else\n\
		throw e;\n\
}'
);
